/*
 *  Copyright 2007 Blandware (http://www.blandware.com)
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package com.blandware.atleap.persistence.core;

import com.blandware.atleap.common.util.PartialCollection;
import com.blandware.atleap.common.util.QueryInfo;
import com.blandware.atleap.model.core.*;

/**
 * <p>DAO for sequence item.</p>
 * <p><a href="SequenceItemDAO.java.html"><i>View Source</i></a></p>
 *
 * @author Roman Puchkovskiy <a href="mailto:roman.puchkovskiy@blandware.com">
 *         &lt;roman.puchkovskiy@blandware.com&gt;</a>
 * @version : $Revision: 1.2 $ : 2007/12/17 13:38:25 $
 */
public interface SequenceItemDAO extends DAO {

	// ~ CRUD Methods ================================================================

	/**
	 * Creates new sequence item (it points to page).
	 *
	 * @param sequenceItem Sequence item object that represents what
     * sequence item must be created
     * @param sequence Sequence to which this sequence item belongs
     * @param page Page to which this sequence item points
	 * @return ID of created sequence item
	 */
	public Long createSequenceItem(SequenceItem sequenceItem, Sequence sequence,
                                   Page page);

	/**
	 * Creates new sequence item (it points to content resource).
	 *
	 * @param sequenceItem Sequence item object that represents what
     * sequence item must be created
     * @param sequence Sequence to which this sequence item belongs
     * @param contentResource Content resource to which this sequence item points
	 * @return ID of created sequence item
	 */
	public Long createSequenceItem(SequenceItem sequenceItem, Sequence sequence,
                                   ContentResource contentResource);

    /**
	 * Retrieves sequence item with specified ID.
	 *
	 * @param sequenceItemId ID to search by
	 * @return Sequence item or null if no sequence item with specified ID
     * exists in database
	 */
	public SequenceItem retrieveSequenceItem(Long sequenceItemId);

	/**
	 * Updates sequence item (it will point to page).
	 *
	 * @param sequenceItem sequence item to update
     * @param sequence sequence to which this item belongs
     * @param page page to which this item will point
	 */
	public void updateSequenceItem(SequenceItem sequenceItem, Sequence sequence,
                                   Page page);

	/**
	 * Updates sequence item (it will point to content resource).
	 *
	 * @param sequenceItem sequence item to update
     * @param sequence sequence to which this item belongs
     * @param contentResource content resource to which this item will point
	 */
	public void updateSequenceItem(SequenceItem sequenceItem, Sequence sequence,
                                   ContentResource contentResource);

    /**
	 * Deletes sequence item.
	 *
	 * @param sequenceItem sequence item to delete
	 */
	public void deleteSequenceItem(SequenceItem sequenceItem);

	// ~ Additional methods ================================================================

	/**
	 * Retrieves filtered/sorted collection of sequence items.
	 *
	 * @param queryInfo Object that contains information about how to filter and sort data
	 * @return Collection of sequence items
	 */
	public PartialCollection listSequenceItems(QueryInfo queryInfo);

    /**
     * Changes an item position so that it becomes one position higher or
     * lower.
     *
     * @param sequenceItem what sequence item to move
     * @param up if true, item is moved up, else down
     */
    public void moveSequenceItem(SequenceItem sequenceItem, boolean up);

    /**
     * Returns least and most positions of item which sequence has given ID.
     *
     * @param sequenceId ID of sequence which children will be considered
     * @return two-element array: least and most occupied positions
     */
    public Integer[] getFirstLastOccupiedPositions(Long sequenceId);

    // ~ Finders ================================================================

}